package com.cheng.student.controller.servlet;

import com.cheng.student.service.StudentServiceImpl;
import com.cheng.student.service.interfaces.StudentService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "GetStudentNumbersServlet", value = "/teacher/GetStudentNumbersServlet")
public class GetStudentNumbersServlet
        extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        StudentService studentService = new StudentServiceImpl();

        int numberOfStudent = studentService.getNumberOfStudent();

        response.getWriter().write("" + numberOfStudent);
    }
}
